<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
selection_test(
  [
    '<div contenteditable>',
      '<table border="1"><tr>',
        '<td width="100px"><span id="span">foo</span></td>',
      '</tr></table>',
      '<div>bar</div>',
    '</div>',
  ],
  selection => {
    assert_not_equals(window.eventSender, undefined,
        'this test requires eventSender');

    const span = selection.document.getElementById('span');
    const x = selection.computeLeft(span) + span.offsetWidth + 10;
    const y = selection.computeTop(span) + span.offsetHeight / 2;

    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();
  },
  [
    '<div contenteditable>',
      '<table border="1"><tbody><tr>',
        '<td width="100px"><span id="span">foo|</span></td>',
      '</tr></tbody></table>',
      '<div>bar</div>',
    '</div>',
  ],
  'Double-click after the last character of table cell');
</script>
